package cn.lh.entity.req;

import cn.lh.entity.dto.UserDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;

/**
 * @描述:
 * @版权: Copyright (c) 2023
 * @作者: linhong
 * @版本: 1.0.0
 * @创建时间: 2023/12/15
 */
@Data
public class UserReq {
    @ApiModelProperty(value = "用户id 修改时必传" )
    private Integer userId;

    @ApiModelProperty(value = "用户名" ,required = true)
    @NotBlank(message = "用户名不能为空")
    @Length(max =  50, message = "长度不能超过50")
    private String userName;

    /**
     * 密码
     */
    @ApiModelProperty(value = "密码" ,required = true)
    @NotBlank(message = "密码不能为空")
    @Length(max =  64, message = "长度不能超过64")
    private String password;

    /**
     * 手机号
     */
    @ApiModelProperty(value = "手机号" ,required = true)
//    @NotBlank(message = "手机号不能为空")
    private String phone;

    /**
     * 地址
     */
    @ApiModelProperty(value = "地址" ,required = true)
//    @NotBlank(message = "地址不能为空")
    private String address;

    public UserDto toDto(){
        UserDto dto = new UserDto();
        dto.setAddress(this.address);
        dto.setPassword(this.phone);
        dto.setName(this.userName);
        dto.setPassword(this.password);
        return dto;
    }
}
